export class TSBufferUtil {

    static Type2SchemaIdDict: { [key: string]: string } = {
        ObjectQueryResponse: "InnerMessage_S_20001/ObjectQueryResponse",
        ObjectQueryRequest: "InnerMessage_S_20001/ObjectQueryRequest",
        A2M_Reload: "InnerMessage_S_20001/A2M_Reload",
        M2A_Reload: "InnerMessage_S_20001/M2A_Reload",
        G2G_LockResponse: "InnerMessage_S_20001/G2G_LockResponse",
        G2G_LockRequest: "InnerMessage_S_20001/G2G_LockRequest",
        G2G_LockReleaseResponse: "InnerMessage_S_20001/G2G_LockReleaseResponse",
        G2G_LockReleaseRequest: "InnerMessage_S_20001/G2G_LockReleaseRequest",
        ObjectAddResponse: "InnerMessage_S_20001/ObjectAddResponse",
        ObjectAddRequest: "InnerMessage_S_20001/ObjectAddRequest",
        ObjectLockResponse: "InnerMessage_S_20001/ObjectLockResponse",
        ObjectLockRequest: "InnerMessage_S_20001/ObjectLockRequest",
        ObjectUnLockResponse: "InnerMessage_S_20001/ObjectUnLockResponse",
        ObjectUnLockRequest: "InnerMessage_S_20001/ObjectUnLockRequest",
        ObjectRemoveResponse: "InnerMessage_S_20001/ObjectRemoveResponse",
        ObjectRemoveRequest: "InnerMessage_S_20001/ObjectRemoveRequest",
        ObjectGetResponse: "InnerMessage_S_20001/ObjectGetResponse",
        ObjectGetRequest: "InnerMessage_S_20001/ObjectGetRequest",
        G2R_GetLoginKey: "InnerMessage_S_20001/G2R_GetLoginKey",
        R2G_GetLoginKey: "InnerMessage_S_20001/R2G_GetLoginKey",
        G2M_SessionDisconnect: "InnerMessage_S_20001/G2M_SessionDisconnect",
        M2M_UnitTransferResponse: "InnerMessage_S_20001/M2M_UnitTransferResponse",
        M2M_UnitTransferRequest: "InnerMessage_S_20001/M2M_UnitTransferRequest",
        L2A_LoginAccountResponse: "InnerMessage_S_20001/L2A_LoginAccountResponse",
        A2L_LoginAccountRequest: "InnerMessage_S_20001/A2L_LoginAccountRequest",
        G2L_DisconnectGateUnit: "InnerMessage_S_20001/G2L_DisconnectGateUnit",
        L2G_DisconnectGateUnit: "InnerMessage_S_20001/L2G_DisconnectGateUnit",
        R2A_GetRealmKey: "InnerMessage_S_20001/R2A_GetRealmKey",
        A2R_GetRealmKey: "InnerMessage_S_20001/A2R_GetRealmKey",
        G2R_GetLoginGateKey: "InnerMessage_S_20001/G2R_GetLoginGateKey",
        R2G_GetLoginGateKey: "InnerMessage_S_20001/R2G_GetLoginGateKey",
        L2G_AddLoginRecord: "InnerMessage_S_20001/L2G_AddLoginRecord",
        G2L_AddLoginRecord: "InnerMessage_S_20001/G2L_AddLoginRecord",
        M2G_RequestEnterGameState: "InnerMessage_S_20001/M2G_RequestEnterGameState",
        G2M_RequestEnterGameState: "InnerMessage_S_20001/G2M_RequestEnterGameState",
        M2G_RequestExitGame: "InnerMessage_S_20001/M2G_RequestExitGame",
        G2M_RequestExitGame: "InnerMessage_S_20001/G2M_RequestExitGame",
        L2G_RemoveLoginRecord: "InnerMessage_S_20001/L2G_RemoveLoginRecord",
        G2L_RemoveLoginRecord: "InnerMessage_S_20001/G2L_RemoveLoginRecord",
        UnitCache2Other_AddOrUpdateUnit: "InnerMessage_S_20001/UnitCache2Other_AddOrUpdateUnit",
        Other2UnitCache_AddOrUpdateUnit: "InnerMessage_S_20001/Other2UnitCache_AddOrUpdateUnit",
        UnitCache2Other_GetUnit: "InnerMessage_S_20001/UnitCache2Other_GetUnit",
        Other2UnitCache_GetUnit: "InnerMessage_S_20001/Other2UnitCache_GetUnit",
        UnitCache2Other_DeleteUnit: "InnerMessage_S_20001/UnitCache2Other_DeleteUnit",
        Other2UnitCache_DeleteUnit: "InnerMessage_S_20001/Other2UnitCache_DeleteUnit",
        HttpGetRouterResponse: "OuterMessage_C_10001/HttpGetRouterResponse",
        RouterSync: "OuterMessage_C_10001/RouterSync",
        M2C_TestResponse: "OuterMessage_C_10001/M2C_TestResponse",
        C2M_TestRequest: "OuterMessage_C_10001/C2M_TestRequest",
        Actor_TransferResponse: "OuterMessage_C_10001/Actor_TransferResponse",
        Actor_TransferRequest: "OuterMessage_C_10001/Actor_TransferRequest",
        G2C_EnterMap: "OuterMessage_C_10001/G2C_EnterMap",
        C2G_EnterMap: "OuterMessage_C_10001/C2G_EnterMap",
        Float3: "OuterMessage_C_10001/Float3",
        Quaternion: "OuterMessage_C_10001/Quaternion",
        MoveInfo: "OuterMessage_C_10001/MoveInfo",
        UnitInfo: "OuterMessage_C_10001/UnitInfo",
        M2C_CreateUnits: "OuterMessage_C_10001/M2C_CreateUnits",
        M2C_CreateMyUnit: "OuterMessage_C_10001/M2C_CreateMyUnit",
        M2C_StartSceneChange: "OuterMessage_C_10001/M2C_StartSceneChange",
        M2C_RemoveUnits: "OuterMessage_C_10001/M2C_RemoveUnits",
        C2M_PathfindingResult: "OuterMessage_C_10001/C2M_PathfindingResult",
        C2M_Stop: "OuterMessage_C_10001/C2M_Stop",
        M2C_PathfindingResult: "OuterMessage_C_10001/M2C_PathfindingResult",
        M2C_Stop: "OuterMessage_C_10001/M2C_Stop",
        G2C_Ping: "OuterMessage_C_10001/G2C_Ping",
        C2G_Ping: "OuterMessage_C_10001/C2G_Ping",
        R2C_Login: "OuterMessage_C_10001/R2C_Login",
        C2R_Login: "OuterMessage_C_10001/C2R_Login",
        G2C_LoginGate: "OuterMessage_C_10001/G2C_LoginGate",
        C2G_LoginGate: "OuterMessage_C_10001/C2G_LoginGate",
        G2C_Test: "OuterMessage_C_10001/G2C_Test",
        M2C_Reload: "OuterMessage_C_10001/M2C_Reload",
        C2M_Reload: "OuterMessage_C_10001/C2M_Reload",
        G2C_TestHotfixMessage: "OuterMessage_C_10001/G2C_TestHotfixMessage",
        M2C_TestRobotCase: "OuterMessage_C_10001/M2C_TestRobotCase",
        C2M_TestRobotCase: "OuterMessage_C_10001/C2M_TestRobotCase",
        M2C_TransferMap: "OuterMessage_C_10001/M2C_TransferMap",
        C2M_TransferMap: "OuterMessage_C_10001/C2M_TransferMap",
        A2C_LoginAccount: "OuterMessage_C_10001/A2C_LoginAccount",
        C2A_LoginAccount: "OuterMessage_C_10001/C2A_LoginAccount",
        A2C_Disconnect: "OuterMessage_C_10001/A2C_Disconnect",
        A2C_GetServerInfos: "OuterMessage_C_10001/A2C_GetServerInfos",
        ServerInfoProto: "OuterMessage_C_10001/ServerInfoProto",
        C2A_GetServerInfos: "OuterMessage_C_10001/C2A_GetServerInfos",
        RoleInfoProto: "OuterMessage_C_10001/RoleInfoProto",
        A2C_CreateRole: "OuterMessage_C_10001/A2C_CreateRole",
        C2A_CreateRole: "OuterMessage_C_10001/C2A_CreateRole",
        A2C_GetRoles: "OuterMessage_C_10001/A2C_GetRoles",
        C2A_GetRoles: "OuterMessage_C_10001/C2A_GetRoles",
        A2C_DeleteRole: "OuterMessage_C_10001/A2C_DeleteRole",
        C2A_DeleteRole: "OuterMessage_C_10001/C2A_DeleteRole",
        A2C_GetRealmKey: "OuterMessage_C_10001/A2C_GetRealmKey",
        C2A_GetRealmKey: "OuterMessage_C_10001/C2A_GetRealmKey",
        R2C_LoginRealm: "OuterMessage_C_10001/R2C_LoginRealm",
        C2R_LoginRealm: "OuterMessage_C_10001/C2R_LoginRealm",
        G2C_LoginGameGate: "OuterMessage_C_10001/G2C_LoginGameGate",
        C2G_LoginGameGate: "OuterMessage_C_10001/C2G_LoginGameGate",
        G2C_EnterGame: "OuterMessage_C_10001/G2C_EnterGame",
        C2G_EnterGame: "OuterMessage_C_10001/C2G_EnterGame"
    };

    static Type2ParentDict: { [key: string]: string } = {
        ObjectQueryResponse: "IActorResponse",
        ObjectQueryRequest: "IActorRequest",
        A2M_Reload: "IActorResponse",
        M2A_Reload: "IActorRequest",
        G2G_LockResponse: "IActorResponse",
        G2G_LockRequest: "IActorRequest",
        G2G_LockReleaseResponse: "IActorResponse",
        G2G_LockReleaseRequest: "IActorRequest",
        ObjectAddResponse: "IActorResponse",
        ObjectAddRequest: "IActorRequest",
        ObjectLockResponse: "IActorResponse",
        ObjectLockRequest: "IActorRequest",
        ObjectUnLockResponse: "IActorResponse",
        ObjectUnLockRequest: "IActorRequest",
        ObjectRemoveResponse: "IActorResponse",
        ObjectRemoveRequest: "IActorRequest",
        ObjectGetResponse: "IActorResponse",
        ObjectGetRequest: "IActorRequest",
        G2R_GetLoginKey: "IActorResponse",
        R2G_GetLoginKey: "IActorRequest",
        G2M_SessionDisconnect: "IActorLocationMessage",
        M2M_UnitTransferResponse: "IActorResponse",
        M2M_UnitTransferRequest: "IActorRequest",
        L2A_LoginAccountResponse: "IActorResponse",
        A2L_LoginAccountRequest: "IActorRequest",
        G2L_DisconnectGateUnit: "IActorResponse",
        L2G_DisconnectGateUnit: "IActorRequest",
        R2A_GetRealmKey: "IActorResponse",
        A2R_GetRealmKey: "IActorRequest",
        G2R_GetLoginGateKey: "IActorResponse",
        R2G_GetLoginGateKey: "IActorRequest",
        L2G_AddLoginRecord: "IActorResponse",
        G2L_AddLoginRecord: "IActorRequest",
        M2G_RequestEnterGameState: "IActorLocationResponse",
        G2M_RequestEnterGameState: "IActorLocationRequest",
        M2G_RequestExitGame: "IActorLocationResponse",
        G2M_RequestExitGame: "IActorLocationRequest",
        L2G_RemoveLoginRecord: "IActorResponse",
        G2L_RemoveLoginRecord: "IActorRequest",
        UnitCache2Other_AddOrUpdateUnit: "IActorResponse",
        Other2UnitCache_AddOrUpdateUnit: "IActorRequest",
        UnitCache2Other_GetUnit: "IActorResponse",
        Other2UnitCache_GetUnit: "IActorRequest",
        UnitCache2Other_DeleteUnit: "IActorResponse",
        Other2UnitCache_DeleteUnit: "IActorRequest",
        HttpGetRouterResponse: "",
        RouterSync: "",
        M2C_TestResponse: "IActorLocationResponse",
        C2M_TestRequest: "IActorLocationRequest",
        Actor_TransferResponse: "IActorLocationResponse",
        Actor_TransferRequest: "IActorLocationRequest",
        G2C_EnterMap: "IResponse",
        C2G_EnterMap: "IRequest",
        Float3: "",
        Quaternion: "",
        MoveInfo: "",
        UnitInfo: "",
        M2C_CreateUnits: "IActorMessage",
        M2C_CreateMyUnit: "IActorMessage",
        M2C_StartSceneChange: "IActorMessage",
        M2C_RemoveUnits: "IActorMessage",
        C2M_PathfindingResult: "IActorLocationMessage",
        C2M_Stop: "IActorLocationMessage",
        M2C_PathfindingResult: "IActorMessage",
        M2C_Stop: "IActorMessage",
        G2C_Ping: "IResponse",
        C2G_Ping: "IRequest",
        R2C_Login: "IResponse",
        C2R_Login: "IRequest",
        G2C_LoginGate: "IResponse",
        C2G_LoginGate: "IRequest",
        G2C_Test: "IMessage",
        M2C_Reload: "IResponse",
        C2M_Reload: "IRequest",
        G2C_TestHotfixMessage: "IMessage",
        M2C_TestRobotCase: "IActorLocationResponse",
        C2M_TestRobotCase: "IActorLocationRequest",
        M2C_TransferMap: "IActorLocationResponse",
        C2M_TransferMap: "IActorLocationRequest",
        A2C_LoginAccount: "IResponse",
        C2A_LoginAccount: "IRequest",
        A2C_Disconnect: "IMessage",
        A2C_GetServerInfos: "IResponse",
        ServerInfoProto: "",
        C2A_GetServerInfos: "IRequest",
        RoleInfoProto: "",
        A2C_CreateRole: "IResponse",
        C2A_CreateRole: "IRequest",
        A2C_GetRoles: "IResponse",
        C2A_GetRoles: "IRequest",
        A2C_DeleteRole: "IResponse",
        C2A_DeleteRole: "IRequest",
        A2C_GetRealmKey: "IResponse",
        C2A_GetRealmKey: "IRequest",
        R2C_LoginRealm: "IResponse",
        C2R_LoginRealm: "IRequest",
        G2C_LoginGameGate: "IResponse",
        C2G_LoginGameGate: "IRequest",
        G2C_EnterGame: "IResponse",
        C2G_EnterGame: "IRequest"
    };

    static Type2ProtocolDict: { [key: string]: number } = {
        ObjectQueryResponse: 20002,
        ObjectQueryRequest: 20003,
        A2M_Reload: 20004,
        M2A_Reload: 20005,
        G2G_LockResponse: 20006,
        G2G_LockRequest: 20007,
        G2G_LockReleaseResponse: 20008,
        G2G_LockReleaseRequest: 20009,
        ObjectAddResponse: 20010,
        ObjectAddRequest: 20011,
        ObjectLockResponse: 20012,
        ObjectLockRequest: 20013,
        ObjectUnLockResponse: 20014,
        ObjectUnLockRequest: 20015,
        ObjectRemoveResponse: 20016,
        ObjectRemoveRequest: 20017,
        ObjectGetResponse: 20018,
        ObjectGetRequest: 20019,
        G2R_GetLoginKey: 20020,
        R2G_GetLoginKey: 20021,
        G2M_SessionDisconnect: 20022,
        M2M_UnitTransferResponse: 20023,
        M2M_UnitTransferRequest: 20024,
        L2A_LoginAccountResponse: 20025,
        A2L_LoginAccountRequest: 20026,
        G2L_DisconnectGateUnit: 20027,
        L2G_DisconnectGateUnit: 20028,
        R2A_GetRealmKey: 20029,
        A2R_GetRealmKey: 20030,
        G2R_GetLoginGateKey: 20031,
        R2G_GetLoginGateKey: 20032,
        L2G_AddLoginRecord: 20033,
        G2L_AddLoginRecord: 20034,
        M2G_RequestEnterGameState: 20035,
        G2M_RequestEnterGameState: 20036,
        M2G_RequestExitGame: 20037,
        G2M_RequestExitGame: 20038,
        L2G_RemoveLoginRecord: 20039,
        G2L_RemoveLoginRecord: 20040,
        UnitCache2Other_AddOrUpdateUnit: 20041,
        Other2UnitCache_AddOrUpdateUnit: 20042,
        UnitCache2Other_GetUnit: 20043,
        Other2UnitCache_GetUnit: 20044,
        UnitCache2Other_DeleteUnit: 20045,
        Other2UnitCache_DeleteUnit: 20046,
        HttpGetRouterResponse: 10002,
        RouterSync: 10003,
        M2C_TestResponse: 10004,
        C2M_TestRequest: 10005,
        Actor_TransferResponse: 10006,
        Actor_TransferRequest: 10007,
        G2C_EnterMap: 10008,
        C2G_EnterMap: 10009,
        Float3: 10010,
        Quaternion: 10011,
        MoveInfo: 10012,
        UnitInfo: 10013,
        M2C_CreateUnits: 10014,
        M2C_CreateMyUnit: 10015,
        M2C_StartSceneChange: 10016,
        M2C_RemoveUnits: 10017,
        C2M_PathfindingResult: 10018,
        C2M_Stop: 10019,
        M2C_PathfindingResult: 10020,
        M2C_Stop: 10021,
        G2C_Ping: 10022,
        C2G_Ping: 10023,
        R2C_Login: 10024,
        C2R_Login: 10025,
        G2C_LoginGate: 10026,
        C2G_LoginGate: 10027,
        G2C_Test: 10028,
        M2C_Reload: 10029,
        C2M_Reload: 10030,
        G2C_TestHotfixMessage: 10031,
        M2C_TestRobotCase: 10032,
        C2M_TestRobotCase: 10033,
        M2C_TransferMap: 10034,
        C2M_TransferMap: 10035,
        A2C_LoginAccount: 10036,
        C2A_LoginAccount: 10037,
        A2C_Disconnect: 10038,
        A2C_GetServerInfos: 10039,
        ServerInfoProto: 10040,
        C2A_GetServerInfos: 10041,
        RoleInfoProto: 10042,
        A2C_CreateRole: 10043,
        C2A_CreateRole: 10044,
        A2C_GetRoles: 10045,
        C2A_GetRoles: 10046,
        A2C_DeleteRole: 10047,
        C2A_DeleteRole: 10048,
        A2C_GetRealmKey: 10049,
        C2A_GetRealmKey: 10050,
        R2C_LoginRealm: 10051,
        C2R_LoginRealm: 10052,
        G2C_LoginGameGate: 10053,
        C2G_LoginGameGate: 10054,
        G2C_EnterGame: 10055,
        C2G_EnterGame: 10056
    };

    static Type2SchemaId(type: string): string {
        let schemaId = TSBufferUtil.Type2SchemaIdDict[type];
        if (!schemaId) {
            throw new Error(`Can not found SchemaId by Type = ${type}!`);
        }
        return schemaId;
    }

    static Type2Parent(type: string): string {
        let parent = TSBufferUtil.Type2ParentDict[type];
        if (!parent) {
            throw new Error(`Can not found Parent by Type = ${type}!`);
        }
        return parent;
    }

    static Type2Protocol(type: string): number {
        let protocol = TSBufferUtil.Type2ProtocolDict[type];
        if (!protocol) {
            throw new Error(`Can not found Protocol by Type = ${type}!`);
        }
        return protocol;
    }

}
